﻿using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Dapper_Core.Web
{
    public static class HttpRequestExt
    {
        public static bool IsAjaxRequest(this HttpRequest request)
        {
            bool result = false;
            //jQuery会自动将 x-requested-with 头加到Headers，其他的框架需要自己添加这个请求头
            if (request.Headers.ContainsKey("x-requested-with"))
            {
                result = request.Headers["x-requested-with"] == "XMLHttpRequest";
            }
            return result;
        }
    }
}
